<!DOCTYPE html>
<html>
<head>
    <title>添加运维人员信息</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link href="../../layui/css/layui.css" rel="stylesheet" type="text/css">
    <script src="../../layui/layui.js"></script>
    <link href="../../css/style.css" rel="stylesheet" type="text/css">
    <script src="../../js/jquery-1.8.3.js"></script>
    <script src="../../js/util.js"></script>
    <script>

        function close(status){
            if(status=="yes"){
                window.parent.location.reload();//刷新父页面
                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                parent.layer.close(index);
            }
            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
            parent.layer.close(index);
        }

        layui.use(['form', 'jquery', 'layer','element'], function () {
            var form = layui.form;
            var $ = layui.$;
            var layer = layui.layer;
            var status = "yes";
            var functionIds = "";
            $('#add').on('click', function () {
                var url = '/xuYiOperator/configureOperator';
                var operatorName = $.trim($("#operatorName").val());
                var operatorMsisdn = $.trim($("#operatorMsisdn").val());
                var talkingCoding = $.trim($("#talkingCoding").val());
               if(isNull(operatorName)){
                   layer.msg("请输入运维人员名称");
               }else if(isNull(operatorMsisdn)){
                   layer.msg("请输入运维人员手机号");
               }else if (testMsisdn(operatorMsisdn)){
                   layer.msg("请输入合法的运维人员手机号");
               }else if(isNull(talkingCoding)){
                   layer.msg("请输入和对讲编码");
               }else {
                var param = {
                    operatorName:operatorName,
                    operatorMsisdn:operatorMsisdn,
                    talkingCoding:talkingCoding,
                    flag: "add"
                };
                $.ajax({
                    type: 'post',
                    data: param,
                    url: url,
                    success: function (data) {
                        if (data == 1) {
                            layer.confirm('添加成功', {
                                btn: ['确认'] //按钮
                            }, function () {
                                close(status);
                            });
                        }else if(data == 2){
                            layer.confirm('手机号及和分期编码均已存在，请更改', {
                                btn: ['确认'] //按钮
                            });
                        }else if(data == 3){
                            layer.confirm('该手机号已存在，请更改', {
                                btn: ['确认'] //按钮
                            });
                        }else if(data == 4){
                            layer.confirm('该和分期编码已存在，请更改', {
                                btn: ['确认'] //按钮
                            });
                        } else {
                            layer.confirm('添加失败，请重试', {
                                btn: ['确认'] //按钮
                            });
                        }
                    },
                    error: function (data) {
                        layer.msg('系统异常，请联系管理员处理!');
                    }
                });
               }
            });
            $('#quit').on('click',function(){
                status="no";
                close(status);
            });
        });


    </script>
</head>
<body>
<div class="layui-content-body">
    <div class="scroll-box">
        <div class="content-box">
            <div class="layui-form layui-form-pane">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 120px">名称</label>
                    <div class="layui-input-inline">
                        <input type="text" name="operatorName" id="operatorName" autocomplete="off" class="layui-input"
                               placeholder="" lay-verify="required" style="width:180px">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 120px">手机号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="operatorMsisdn" id="operatorMsisdn" autocomplete="off" class="layui-input"
                               placeholder="" lay-verify="required" style="width:180px">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 120px">和对讲编码</label>
                    <div class="layui-input-inline">
                        <input type="text" name="talkingCoding" id="talkingCoding" autocomplete="off" class="layui-input"
                               placeholder="" lay-verify="required" style="width:180px">
                    </div>
                </div>

                <div class="layui-block" pane="" style="padding-left:40px;">
                    <button class="layui-btn layui-btn-normal" lay-filter="add" id="add" style="min-width: 100px">添加</button>
                    <button class="layui-btn layui-btn-normal" lay-filter="quit" id="quit" style="min-width: 100px">取消</button>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
</html>